package com.egao.common.publicly;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.egao.common.core.web.JsonResult;
import com.egao.common.core.web.PageResult;
import com.egao.common.module.world.entity.WorldGameLink;
import com.egao.common.module.world.service.WorldGameLinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 济世杯banner公开接口
 * @author lsj
 */
@Api(tags = "济世杯公开banner")
@RestController
@RequestMapping("${api}")
public class PubliclyWorldGameBannerController {
    @Autowired
    private WorldGameLinkService worldGameLinkService;

    @ApiOperation(value = "banner列表")
    @GetMapping("/publicly/world-game/banner")
    public JsonResult page(String title) {
       List<WorldGameLink> list = worldGameLinkService.list(new LambdaQueryWrapper<WorldGameLink>()
                .like(!StrUtil.isBlank(title), WorldGameLink::getTitle, title)
               .orderByAsc(WorldGameLink::getSort)
               .orderByDesc(WorldGameLink::getCreateTime)
        );
        return JsonResult.ok().setData(list);
    }

}
